<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../resct18/react.development.js"></script>
    <script src="../resct18/react-dom.development.js"></script>
    <script src="../resct18/babel.min.js"></script>
</head>
<body>
    <div id="app"></div>
    <button id="btn">修改vDOM,并重新渲染</button>
    <script type="text/babel">
        /* 
            组件实例有一个state属性,当state属性发生改变的时候,组件会重新执行render得到一个新的虚拟DOM,然后开始diffing算法,并重新渲染
        
        */
        class Content extends React.Component{
            //state属性值是一个对象
            state={
                content:'真厉害',
                count:0,
                isHot:true
            }

            //render的这种写法在原型对象上,只有实例化对象能够调用 它里面的this指向实例化对象
            render(){
                const {count,content,isHot}=this.state
                return (
                    <div>
                    <h1>{this.state.count}</h1>
                    {/* 想要拿到state属性里面的变量,state是组件实例的一个属性,this指向实例化对象(组件实例) */}
                    <h1>{count}</h1>
                    <p>{content}</p>
                    <p>{isHot?'热啊':'冷啊'}</p>
                    </div>
                )
            }
            
        }

       const root=ReactDOM.createRoot(document.getElementById('app'));
       root.render(<Content/>)


    </script>
</body>
</html>